package com.ys.erp.stage_emp_service.controller;

import com.ys.erp.framework.annotation.CheckEmpLogin;
import com.ys.erp.framework.annotation.ResponseResult;
import com.ys.erp.framework.annotation.StageLoginEmp;
import com.ys.erp.framework.bean.dto.StageEmpDTO;
import com.ys.erp.framework.response.PageDTO;
import com.ys.erp.stage_emp_service.bean.conditon.EmpCondition;
import com.ys.erp.stage_emp_service.bean.vo.EmpLoginVO;
import com.ys.erp.stage_emp_service.bean.vo.EmpShopInfoVO;
import com.ys.erp.stage_emp_service.bean.vo.EmployeeVo;
import com.ys.erp.stage_emp_service.bean.vo.ShopInfoVO;
import com.ys.erp.stage_emp_service.service.EmpService;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lwj
 * @date 2025/5/19
 */
@ResponseResult
@RestController
@RequiredArgsConstructor
@RequestMapping("/manage/emp/")
@Tag(name = "员工登录相关接口", description = "员工登录相关接口")
public class EmpController {

    private final EmpService empService;

    @PostMapping("empLogin")
    @Operation(summary = "员工登录", description = "员工登录")
    public EmpLoginVO empLogin(@RequestBody @Valid EmpCondition.EmpLoginCondition con) {
        return empService.empLogin(con);
    }


    @GetMapping("getEmpShopInfoList")
    @Operation(summary = "获取员工店铺信息列表", description = "获取员工店铺信息列表")
    @CheckEmpLogin
    public List<ShopInfoVO> getEmpShopInfoList(@StageLoginEmp StageEmpDTO empDto) {
        return empService.getEmpShopInfoList(empDto);
    }

    @GetMapping("chooseShop")
    @Operation(summary = "员工选择店铺", description = "员工选择店铺")
    @CheckEmpLogin
    public EmpShopInfoVO chooseShop(@StageLoginEmp StageEmpDTO empDto, @RequestParam(value = "shopCode") String shopCode) {
        return empService.chooseShop(empDto, shopCode);
    }

    @GetMapping("getEmpShopList")
    @Operation(summary = "获取员工店铺列表", description = "获取员工店铺列表")
    @CheckEmpLogin
    public List<ShopInfoVO> getEmpShopList(@StageLoginEmp StageEmpDTO empDto, @RequestParam(value = "empId") Long empId) {
        return empService.getEmpShopList(empDto,empId);
    }


    @PostMapping("empSettingShop")
    @Operation(summary = "员工设置店铺", description = "员工设置店铺")
    @CheckEmpLogin
    public void empSettingShop(@StageLoginEmp StageEmpDTO empDto, @RequestBody EmpCondition.EmpSettingShopCon con) {
        empService.empSettingShop(empDto, con);
    }

    @PostMapping("/pageList")
    @Operation(summary = "分页员工列表", description = "分页员工列表")
    @CheckEmpLogin
    public PageDTO<EmployeeVo> pageEmp(@RequestBody @Valid EmpCondition.PageEmployeeCon pageEmployeeCon,
                                       @StageLoginEmp StageEmpDTO empDto) {
        return empService.pageEmp(empDto,pageEmployeeCon);
    }
    @PostMapping("/addOrUpdateEmployee")
    @Operation(summary = "添加或编辑员工", description = "添加或编辑员工")
    @CheckEmpLogin
    public void addOrUpdateEmployee(@RequestBody @Valid EmpCondition.AddOrUpdateEmpCon con,
                                    @StageLoginEmp StageEmpDTO empDto) {
        empService.addOrUpdateEmployee(empDto, con);
    }
}
